package leetcode.code1447;

import java.util.ArrayList;
import java.util.List;

import leetcode.IDebug;

//执行用时：19 ms, 在所有 Java 提交中击败了84.75%的用户
//
//内存消耗：42.5 MB, 在所有 Java 提交中击败了5.32%的用户
//
//通过测试用例：100 / 100
public class Solution implements IDebug {

	public List<String> simplifiedFractions(int n) {
		List<String> ans = new ArrayList<>();
		for (int down = n; down >= 2; down--) {
			for (int up = down - 1; up >= 1; up--) {
				if (this.gcd(down, up) == 1) {
					ans.add(up + "/" + down);
				}
			}
		}
		return ans;
	}

	public int gcd(int down, int up) {
		return up == 0 ? down : gcd(up, down % up);
	}

	@Override
	public void debug1() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug2() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug3() {
		// TODO Auto-generated method stub

	}

	@Override
	public void debug4() {
		// TODO Auto-generated method stub

	}

	public static void main(String[] args) {
		Solution so = new Solution();
		so.debug1();
		so.debug2();
		so.debug3();
		so.debug4();
		System.out.println(so.gcd(4, 2));
		so.simplifiedFractions(4);
	}

}
